package com.hckj.jianzhijia;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hckj.jianzhijia.listeners.OnBackClickListener;
import com.hckj.jianzhijia.utils.SharedPreferencesUtil;
import com.rey.material.widget.Switch;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class SettingActivity extends BaseActivity {

    @InjectView(R.id.imgv_go_back)
    ImageView imgvGoBack;
    @InjectView(R.id.tv_title)
    TextView tvTitle;
    @InjectView(R.id.rl_toolbar)
    RelativeLayout rlToolbar;
    @InjectView(R.id.imgv_bell)
    ImageView imgvBell;
    @InjectView(R.id.sw_bell)
    Switch swBell;
    @InjectView(R.id.imgv_vibration)
    ImageView imgvVibration;
    @InjectView(R.id.sw_vibration)
    Switch swVibration;
    @InjectView(R.id.imgv_auto_update)
    ImageView imgvAutoUpdate;
    @InjectView(R.id.sw_auto_update)
    Switch swAutoUpdate;

    private SharedPreferencesUtil sharedPreferencesUtil;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.inject(this);
        sharedPreferencesUtil = new SharedPreferencesUtil(this);
        initData();
        initEvent();

    }

    private void initData() {
        if(sharedPreferencesUtil.ifAutoUpdate()){
            swAutoUpdate.setChecked(true);
        }else{
            swAutoUpdate.setChecked(false);
        }
    }

    private void initEvent() {

        imgvGoBack.setOnClickListener(new OnBackClickListener(this));
        swAutoUpdate.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(Switch view, boolean checked) {
                    sharedPreferencesUtil.setAutoUpdate(checked);
            }
        });



    }


}
